// 将
exports.arrayToTree = function (arr, pid = 0) {
  const target = JSON.parse(JSON.stringify(arr));
  return target
    .filter((p) => {
      const _c = target
        .filter((c) => c.pid === p.id)
        .sort((a, b) => a.sort - b.sort);
      _c.length && (p.children = _c);
      return p.pid === pid;
    })
    .sort((a, b) => a.sort - b.sort);
};
